package com.zrc.japktool.apk.lib2cppTools.tools;

import java.io.File;

public class SymbleFileHelper {
    private static volatile SymbleFileHelper instance = null;
    private String name;

    private SymbleFileHelper() {
        String path = SettingHelper.getInstance().getProjectPath();
        String filename = path + File.separator + "symble.txt";
        String SoPath = path + File.separator + "app" + File.separator + "src" + File.separator + "main" + File.separator + "jniLibs" + File.separator + "arm64-v8a" + File.separator + "libil2cpp.so";
        if (OSDetector.getOS() == OSDetector.win) {
            String objdumpCmd = "." + File.separator + "bin" + File.separator + "aarch64-linux-android-objdump.exe -T " + SoPath + " > " + filename;
            Cmd.run(objdumpCmd);
        } else if (OSDetector.getOS() == OSDetector.linux) {
            String[] objdumpCmd = new String[]{"." + File.separator + "bin" + File.separator + "aarch64-linux-android-objdump", "-T", SoPath};
            Cmd.run(objdumpCmd, filename);
        }
        this.setName(filename);
    }

    public static SymbleFileHelper getInstance() {
        if (instance == null) {
            synchronized(SymbleFileHelper.class) {
                if (instance == null) {
                    instance = new SymbleFileHelper();
                }
            }
        }

        return instance;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
